const {Validator,Rule} = require('../core/validate.js')

const phone = [
    new Rule('isLength', '手机号长度不一致，必须为11位', { min: 11, max: 11 }),
    new Rule('isInt', '手机号必须为数字')
]

const email = [
    new Rule('isEmail','email格式不正确')
]

const password = [
    new Rule('isLength','密码长度不一致，最大长度16，最小长度11',{min:11,max:16})
]

const code = [
    new Rule('isLength', '验证码长度不一致，必须为6位', { min: 6, max: 6 }),
    new Rule('isInt', '验证码必须为数字')
]

class LoginValidator extends Validator{
    constructor() {
        super()
        this.rules = {
            username: [
                new Rule('isLength', '用户名长度不一致', { min: 6, max: 255 })
            ],
            password
        }
    }
}
class CodeLoginValidator extends Validator{
    constructor() {
        super()
        this.rules = {
            phone,
            code
        }
    }
}

class RegisterValidator extends Validator{
    constructor() {
        super()
        this.rules = {
            phone,
            password,
            code
        }
    }
}

class PhoneValidator extends Validator{
    constructor() {
        super()
        this.rules = {
            phone
        }
    }
}

class BindEmailValidator extends Validator{
    constructor() {
        super()
        this.rules = {
            email
        }
    }
}


module.exports = {
    LoginValidator,
    RegisterValidator,
    PhoneValidator,
    BindEmailValidator,
    CodeLoginValidator
}